<?php
/**
 * Description of AbstractComponent
 *
 * @author Rino7
 */
abstract class AbstractComponent {

    /**
    * The name that have the form element
    * @var string 
    */
    protected $_formName;

    /**
	* The label for the form element
	* @var string
	*/
    protected $_label = "";

    /**
	* The value stored in the db of the form element
	* @var mix 
	*/
    protected $_value;

    /**
	* The id of the form element
	* @var string 
	*/
    protected $_id;

    /**
	* The default value of the form element
	* @var mix 
	*/
    protected $_defaultValue = "";

    /**
	* The css classes set to the form element
	* @var array 
	*/
    protected $_cssClasses = array();

    /**
	* The mode that will be saved the data of the form element.
	* @example:
	*   oneToOne: save the data in the self table
	*   oneToMany: save the data in other table, sending a package of data,
	*   for instance: a photo gallery belongs to one notice
	* @var string 
	*/
    protected $_saveMode;

    /**
	* The name of the mapped field in the data base
	* @var string 
	*/
    protected $_dbFieldName = "";

    /**
	* An array of links of javascripts calls.
	* @var array 
	*/
    protected static $_javascriptCalls = array();

    //sacar de acá, ponerlo en el radio button y en el checkbox
    const CHECKED_STRING = "checked='checked'";
    
    const ONE_TO_MANY = "OneToMany";
    const ONE_TO_ONE = "OneToOne";

    protected function __construct($elementName = "") 
    {
	if(!empty($elementName)) {
		$this->_formName = $elementName;
	}
    }

    protected function addJavascriptCallsToHtml($javascriptSrc) {
	if(!in_array($javascriptSrc, self::$_javascriptCalls)) {
	    array_push(self::$_javascriptCalls, $javascriptSrc);
	}
    }

    protected function addCssCallsToHtml() 
    {

    }

    abstract function render();
        
        // <editor-fold desc="Getters and Setters.">
    
    //FormName
    public function getFormName()
    {
        return $this->_formName;
    }
    
    public function setFormName($name)
    {
        $this->_formName = $name;
    }
    
        
    //Label
    public function getLabel()
    {
        return $this->_label;
    }
    
    public function setLabel($label)
    {
        $this->_label = $label;
    }
    
    //DbFieldName
    public function getDbFieldName()
    {
        return $this->_dbFieldName;
    }
    
    public function setDbFieldName($dbFieldName)
    {
        $this->_dbFieldName = $dbFieldName;
    }
    
    //SaveMode
    public function getSaveMode()
    {
        return $this->_saveMode;
    }
    
    public function setSaveMode($saveMode)
    {
        $this->_saveMode = $saveMode;
    }
    
    //Value
    public function getValue()
    {
        return $this->_value;
    }
    
    public function setValue($value)
    {
        $this->_value = $value;
    }
    
    //Value
    public function getId()
    {
        return $this->_id;
    }
    
    public function setId($id)
    {
        $this->_id = $id;
    }
    
    //DefaultValue
    public function getDefaultValue()
    {
        return $this->_defaultValue;
    }
    
    public function setDefaultValue($defaultValue)
    {
        $this->_defaultValue = $defaultValue;
    }
    
    //Css classes
    public function getCssClasses()
    {
        return $this->_cssClasses;
    }
    
    public function setCssClasses($cssClasses)
    {
        $this->_cssClasses = $cssClasses;
    }
    
    public static function getJavascriptCalls()
    {
	return self::$_javascriptCalls;
    }
    // </editor-fold>
    
}

?>
